<template>
	<om-formsub-outer :index="index" :checkedit="checkedit" :deleteBtn="false">
		<om-autoform ref="autoform" :initConfigData="autoformdata" :initValue="initValue"></om-autoform>
	</om-formsub-outer>
</template>

<script>
	import {buildSubFormData, subOnLoad, changeEditor,configSelectData,hasValue} from '@/static/js/formUtil.js';
	import { ignoreHtml,ptFloat,minusF,getDateStr} from '@/static/js/common.js';
	export default {
		provide() {
			return {
				formPage: this
			};
		},
		data() {
			return buildSubFormData({
				projectScoreNum: ''
			})
		},
		methods:{
			initLoad(){
				let _that = this
				let pro1 = _that.om.request('dictZero/getListByCode', { code: "36802" });
				let pro2 = _that.om.request('tsysdict/getCombobox', { code: "38589" });
				Promise.all([pro1, pro2]).then(res=>{
					_that.$refs.autoform.changeEditor("title3", "assessmentResultId", "data", configSelectData(res[0],"id","dicname"))
					_that.$refs.autoform.initSelectIndex("title3", "assessmentResultId")
					_that.$refs.autoform.changeEditor("title3", "trainResultId", "data", configSelectData(res[1],"id","dicname"))
					_that.$refs.autoform.initSelectIndex("title3", "trainResultId")
				})
			},
			onSelectAssessmentResult(data){
				if(data.id == 4782){
					this.$refs.autoform.formdata.trainResultId = 4496
					this.$refs.autoform.initSelectIndex("title3", "trainResultId")
					this.$refs.autoform.formdata.scoreNum = parseFloat('-' + this.projectScoreNum)
				}else{
					this.$refs.autoform.formdata.trainResultId = 4495
					this.$refs.autoform.initSelectIndex("title3", "trainResultId")
					this.$refs.autoform.formdata.scoreNum = parseFloat(this.projectScoreNum)
				}
			},
			onSelectTrainResult(data){
				if(data.id == 4495){
					this.$refs.autoform.formdata.scoreNum = parseFloat(this.projectScoreNum)
				}
				else if(data.id == 4496){
					this.$refs.autoform.formdata.scoreNum = parseFloat('-' + this.projectScoreNum)
				}else{
					this.$refs.autoform.clear("title3","scoreNum")
				}
			},
			clearTrainResult(){
				this.$refs.autoform.clear("title3","trainResultId")
				this.$refs.autoform.clear("title3","trainResultName")
				this.$refs.autoform.clear("title3","scoreNum")
			}
		},
		onShow() {
			
		},
		onLoad(e) {
			let _that = this
			subOnLoad(_that, e, function() {
				if(e.configDataCacheKey){
					uni.getStorage({
						key: e.configDataCacheKey,
						success: function(res) {
							if(res.data && Object.prototype.toString.call(res.data)==='[object Array]'){
								_that.autoformdata = res.data
								Object.assign(_that.initValue, _that.formdata)
								_that.autoformdata[0].order = _that.order
								_that.projectScoreNum = uni.getStorageSync('projectScoreNumKey')
								_that.initLoad()
							}
						}
					})
				}			
			})
		}
	}
</script>

<style>
</style>                                                                                                                                                                                                                                                                                                                                                                                                                                                         
